<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<html>
<head> 
	<title>Videshop POS</title> 
	<link href="../css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
	<f:view>
		<table border="0" cellpadding="0" cellspacing="10">
			<tr>
				<td colspan="2"><h1>Videoshop POS</h1></td>
			</tr>
			<tr>
				<td valign="top">
					<table border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td>
								<!-- User section -->
								<f:subview id="userSection">
									<jsp:include page="user.jsp"/>
								</f:subview>
							</td>
						</tr>
						<tr>
							<td>
								<!-- Menu section -->
								<f:subview id="menuSection">
									<jsp:include page="menu.jsp"/>
								</f:subview>
							</td>
						</tr>
					</table>
				</td>
				<td valign="top" class="mainSection">
					<c:choose>
						<c:when test="${!empty userSection.staff}">
							<h2>Titles</h2>

							<h:form id="titleForm">
								<h:panelGrid columns="2">
									<h:outputText styleClass="label" value="Name"/>
									<h:inputText styleClass="text200" value="#{titleSection.searchCriteria.titleName}"/>
									<h:outputText styleClass="label" value="Category"/>
									<h:selectOneListbox	styleClass="select200" size="1" value="#{titleSection.searchCriteria.categoryId}">
										<f:selectItems value="#{titleSection.searchCategories}"/>
									</h:selectOneListbox>
									<h:commandLink styleClass="button" action="#{titleSection.selectCategory}">
										<f:verbatim escape="true">Search</f:verbatim>
									</h:commandLink>
								</h:panelGrid>
								
								<h:dataTable 	id="titleTable" 
												styleClass="dataTable"
												columnClasses="titleTable2ImageColumn,titleTable2TitleColumn,titleTable2ClassificationColumn,titleTable2ActionColumn"
												value="#{titleSection.titles}"
												var="title"
								>
									<h:column headerClass="titleTable2ImageColumn">
										<f:facet name="header">
										</f:facet>
										<h:graphicImage url="#{title.iconUrl}"/>
									</h:column>
									<h:column headerClass="titleTable2TitleColumn">
										<f:facet name="header">
											<h:commandLink 	action="#{titleSection.sortByTitle}">
												<f:verbatim escape="true">Title</f:verbatim>
											</h:commandLink>
										</f:facet>
										<h:outputText value="#{title.titleName}"/>
									</h:column>
									<h:column headerClass="titleTable2ClassificationColumn">
										<f:facet name="header">
											<h:commandLink 	action="#{titleSection.sortByClassification}">
												<f:verbatim escape="true">Classification</f:verbatim>
											</h:commandLink>
										</f:facet>
										<h:graphicImage url="#{title.classification.iconUrl}" height="45"/>
									</h:column>
									<h:column headerClass="titleTable2ActionColumn">
										<f:facet name="header">
											<f:verbatim escape="true">Action</f:verbatim>
										</f:facet>
										<c:if test="${userSection.staff.seniorManager}">
											<h:commandLink styleClass="longButton" action="#{titleSection.editTitle}">
												<f:verbatim escape="true">Edit</f:verbatim>
											</h:commandLink>
										</c:if>
										<h:commandLink styleClass="longButton" action="#{titleSection.editTitleCopies}">
											<f:verbatim escape="true">Manage Copies</f:verbatim>
										</h:commandLink>
										<c:if test="${userSection.staff.seniorManager}">
											<h:commandLink styleClass="button" action="#{titleSection.delete}">
												<f:verbatim escape="true">Delete</f:verbatim>
											</h:commandLink>
										</c:if>
									</h:column>
								</h:dataTable>
								<c:if test="${userSection.staff.seniorManager}">
									<h:commandLink styleClass="button" action="#{titleSection.add}">
										<f:verbatim escape="true">Add</f:verbatim>
									</h:commandLink>
								</c:if>
							</h:form>
						</c:when>
						<c:otherwise>
							Please login
						</c:otherwise>
					</c:choose>
				</td>
			</tr>
		</table>
	</f:view>
</html>